<?php
declare (strict_types = 1);

namespace app\controller;

use app\BaseController;
use app\model\Config;
use app\model\Loan;
class LoanController extends BaseController
{
	
	function getLoanConfig()
	{
		$row = Config::getFieldByName('loan','value');
		$this->writeJson(json_decode($row));
	}
	
	function createLoan()
	{
		$type = $this->request->post('type/d');
		$count = $this->request->post('count/d');
		$price = $this->request->post('price');
		$name = $this->request->post('name');
		$mobile = $this->request->post('mobile');
		
		Loan::create([
			'user_id'=>$this->user_id,
			'type'=>$type,
			'count'=>$count,
			'price'=>$price,
			'name'=>$name,
			'mobile'=>$mobile,
		]);
		$this->writeJson();
	}
	
}
